var killSW = false;
if ('serviceWorker' in navigator) {
    window.addEventListener('load', () => {
        const killSW = window.killSW || false;
        if (killSW)
        {
            navigator.serviceWorker.getRegistration('/service-worker').then(registration => {
                // 手动注销
                if (typeof registration !='undefined')
                {
                    registration.unregister();
                    // 清除缓存
                    window.caches && caches.keys && caches.keys().then(function(keys) {
                        keys.forEach(function(key) {
                            caches.delete(key);
                        });
                    });
                }
            })
        }
        else
        {
            navigator.serviceWorker.register('/service-worker.js');
        }
    });
}